Create SFTP only user in Linux
· One min read
Create user
-s /sbin/nologin
: disable login-M
: don't create home directory-d <home directory>
: home directory
# sudo user <user> -s /sbin/nologin -M -d <home directory>
sudo user sftp-user -s /sbin/nologin -M -d /var/www/html/
Set password
# sudo passwd <user>
sudo passwd sftp-user
Add this to /etc/ssh/sshd_config
# Match User <user>
Match User sftp-user
ForceCommand internal-sftp
AllowTcpForwarding no
X11Forwarding no